<template>
    <div>
        <div class="swiper-container" ref="floor1Swiper">
                <div class="swiper-wrapper">
                  <div class="swiper-slide" v-for="carouse in list" :key="carouse.id">
                    <img :src="carouse.imgUrl" />
                  </div>
                  <!-- <div class="swiper-slide">
                    <img src="./images/floor-1-b02.png" />
                  </div>
                  <div class="swiper-slide">
                    <img src="./images/floor-1-b03.png" />
                  </div> -->
                </div>
                <!-- 如果需要分页器 -->
                <div class="swiper-pagination"></div>

                <!-- 如果需要导航按钮 -->
                <div class="swiper-button-prev"></div>
                <div class="swiper-button-next"></div>
              </div>
    </div>
</template>
<script>
import Swiper from "swiper"
export default {
    name:"Carousel",
    props:["list"],
    watch:{
        list:{
        immediate:true ,
        handler(newValue,oldValue){ 
            // console.log("我在这里");          //照着这个写有点问题,监听不到，使用immediate：true去直接执行一次
            this.$nextTick(()=>{                //使用这里可以保持和在listContainer中的代码风格一样，
                var mySwiper = new Swiper (this.$refs.floor1Swiper  , {
                loop: true, // 循环模式选项
                // 如果需要分页器
                pagination: {
                el: '.swiper-pagination',
                clickable :true, //分页
                },
                // 如果需要前进后退按钮
                navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
                    },
                }) 
                })
            }
        }
    }
}
</script>
<style lang="">
    
</style>